<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>一寸照片审核</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<style type="text/css">
    .layui-btn-sm{color:#fff!important;}
</style>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form">
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <div class="operright cyt-retract-close hideMenu"> 收起筛选<i class="iconfont">&#xe658;</i></div>
                    <div class="operright cyt-retract-open showMenu" style="display: none;"> 展开筛选<i class="iconfont">&#xe936;</i></div>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="allselect"><i class="iconfont marr5">&#xe68f;</i>全选</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="allPass"><i class="iconfont marr5">&#xe624;</i>批量通过</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="allnotPass"><i class="iconfont marr5">&#xe654;</i>批量不通过</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="selectDown"><i class="iconfont marr5">&#xe6b3;</i>批量下载</button>
                    <!--<button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="allDown"><i class="iconfont marr5">&#xe6b3;</i>全部下载</button>-->
                    <div class="triangle-bottom"></div>
                    <div class="triangle-top"></div>
                </div>
                <div class="search-details">
                    <div class="layui-form-item marb5">
                        <!--search开始-->
                        <div class="layui-inline">
                            <label class="layui-form-label">姓名：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name" placeholder="请输入名称" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!--search结束-->
                        <div class="layui-inline marl8">
                            <button class="layui-btn layui-btn-normal" type="button" id="searchBtn">搜索</button>
                            <button class="layui-btn layui-btn-normal" type="button" id="resetBtn">重置</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="one-inchpic-look-ctn clearfix" id="content">
            </div>
        </form>

        <!--<div id="page">-->
        <!--</div>-->
    </div>
</div>
<!--操作-->
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    var applyId='${applyId}';
    var page = null;
    var baseutil = null;
    var dialog = null;
    var form = null;
    var curr = 1;// 当前页，初始值设为 1
    var limit = 10;// 每页条数，初始值设为 10
    var total;// 总记录数
    var flag = 0;
    var imgId ="";
    var names ="";
    layui.use(['jquery', 'table', 'page', 'dialog','form','baseutil'], function () {
        var $ = layui.jquery,
            page = layui.page,
            table = layui.table;
            dialog = layui.dialog;
            form = layui.form;
           baseutil = layui.baseutil;


        $(document).ready(function () {
            getInfo();// 获取数据
            toPage();// 进行分页

        });

        function getInfo() {
            var name = $("#name").val();
            $.ajax({
                type: "post",
                url: "/wx/wxeducationuser/getAllStudentImageCheck",
                async: false,// 设置同步请求，加载数据前锁定浏览器
                dataType: 'json',
                data: {
                    "page": curr, // 查询页码
                    "limit": limit, // 每页条数
                    "name":name,
                    "applyId":applyId

                },
                success: successFu
            });
        }

        // 数据请求成功
        function successFu(pager) {
            $("#content").html("");
            // limit = pager.limit;
            total = pager.count;
            // 3.渲染数据
            // 当前查询无数据时
            if (pager.total == 0) {
                // $("tbody").html("<tr><td colspan='7' class='text-center'>暂无数据</td></tr>");
                return;
            }
            var text = '<ul>';
            $.each(pager.data, function (i, item) {
                text+='<li>'+
                        '<div class="checkedbtn"><input type="checkbox" name="imageCheckbox" title="" lay-skin="primary" id="' + item.id + '" data-imgId="' + item.issnumImageUrl+ '" data-examine="' + item.examine+ '" data-name="' + item.name+ '" ></div>'+
                        '<div class="one-inchpic" style="background: url('+item.issnumImageUrl+') center no-repeat;background-size: cover"></div>'+
                        '<div class="div-line-txt"><span style="letter-spacing:14px;">姓名</span>'+":"+item.name+'</div>'+
                        '<div class="div-line-txt"><span>上传时间：</span>'+item.userNumber+'</div>';
                if(item.examine=="2"){
                    text+= '<div class="mart30">'+
                            '<button class="layui-btn layui-btn-normal layui-btn-sm" type="button" id="'+item.id+'" onclick="pass(\''+ item.id+'\')">通过</button>'+
                            '<button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-danger" type="button"  id="'+item.id+'" onclick="nopass(\''+ item.id+'\')">驳回</button>'+
                            '</div>'

                }else if(item.examine=="1"){//拒绝
                    text+= ' <div class="div-line-txt"><span>审核状态：</span><span class="red">未通过</span></div>';

                }else if(item.examine=="0"){//通过
                    text+= '<div class="div-line-txt"><span>审核状态：</span><span class="green">通过</span></div>';
                }

                text+= '</li>';
            });
            text +='</ul>';

            $("#content").html(text);
            form.render('checkbox');

        }
        //全选

        $('#allselect').bind('click', function () {
            if (flag == 0) {
                $("input[type=checkbox]").prop('checked',true);
//
                flag =1;
            } else {
                $("input[type=checkbox]").prop('checked',false);

                flag = 0;
            }
            form.render(); //重新渲染
        });

        //批量通过
        $('#allPass').bind('click', function () {
            var arr = [];
            $(":checkbox[name='imageCheckbox']:checked").each(function (i, e) {
                arr.push(e.id);
            });
            if (arr.length == 0) {
                dialog.msg("请选择批量通过的图片");
                return false;
            }
            var ids = arr.join(",");
            var state = getExamine();
            if (state.indexOf("0")>-1||state.indexOf("1")>-1){
                dialog.msg("请选择未审核的图片");
                return false;
            }
            baseutil.post('/wx/wxeducationuser/moreImageOfStudentCheck', {"examine": "0","ids":ids}, function (result) {
                if (0 == result.code) {
                    dialog.msg("通过成功");
                    getInfo();// 获取数据
                    toPage();// 进行分页
                }else {
                    dialog.msg("通过失败");
                }
            });


        });


        //批量不通过
        $('#allnotPass').bind('click', function () {
            var arr = [];
            $(":checkbox[name='imageCheckbox']:checked").each(function (i, e) {
                arr.push(e.id);
            });
            if (arr.length == 0) {
                dialog.msg("请选择批量不通过的图片");
                return false;
            }
            var ids = arr.join(",");
            var state = getExamine();
            if (state.indexOf("0")>-1||state.indexOf("1")>-1){
                dialog.msg("请选择未审核的图片");
                return false;
            }
            baseutil.post('/wx/wxeducationuser/moreImageOfStudentCheck', {"examine": "1","ids":ids}, function (result) {
                if (0 == result.code) {
                    dialog.msg("通过成功");
                    getInfo();// 获取数据
                    toPage();// 进行分页
                }else {
                    dialog.msg("通过失败");
                }
            });

        });

        //批量下载
        $('#selectDown').bind('click', function () {
            imgId = getImgId();
            names = getUserName();

            if(imgId.length == 0){
                dialog.msg("请选择批量下载的图片");
                return false;
            }
            var array = imgId.split(',');
            for(var i=0;i<array.length;i++){
                var str = array[i];
                var strname = names[i];
                if(str!=""){
                    var a = document.createElement('a');          // 创建一个a节点插入的document
                    var event = new MouseEvent('click');           // 模拟鼠标click点击事件
                    a.download = strname+'的一寸照片';                  // 设置a节点的download属性值
                    a.href = str;                                 // 将图片的src赋值给a节点的href
                    a.dispatchEvent(event)
                }
            }
        });
        //全部下载
        $('#allDown').bind('click', function () {


        });

        // 查询
        $('#searchBtn').bind('click', function () {
            getInfo();// 获取数据
            toPage();// 进行分页
        });
        // 重置
        $('#resetBtn').bind('click', function () {
            $("#name").val("");
            getInfo();// 获取数据
            toPage();// 进行分页
        });

        // 进行分页
        function toPage() {
            // 调用分页
            layui.use('laypage', function () {
                var laypage = layui.laypage;
                // 调用分页
                laypage.render({
                    // 分页容器的id
                    elem: 'page',// *必选参数
                    // 数据总数，从服务端得到
                    count: total,// *必选参数
                    // 每页显示的条数。laypage将会借助 count 和 limit 计算出分页数。
                    //limit:limit,
                    // 起始页
                    //curr:Pager,
                    // 连续出现的页码个数
                    //groups:5,
                    // 自定义每页条数的选择项
                    limits: [10, 25, 50, 100],
                    // 自定义首页、尾页、上一页、下一页文本
                    first: '首页',
                    last: '尾页',
                    prev: '<em><<</em>',
                    next: '<em>>></em>',
                    // 自定义主题
                    theme: "#FF5722",
                    // 自定义排版
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
                    // 渲染数据
                    jump: function (data, first) {
                        // data包含了当前分页的所有参数
                        curr = data.curr;
                        limit = data.limit;

                        // 首次不执行
                        if (!first) {
                            getInfo();
                        }
                    }
                });
            })
        }

    });
    function pass(id) {
        baseutil.post('/wx/wxeducationuser/oneImageOfStudentCheck', {"examine": "0","id":id}, function (result) {
            if (0 == result.code) {
                dialog.msg("通过成功");
                getInfo();// 获取数据
                toPage();// 进行分页
            }else {
                dialog.msg("通过失败");
            }
        });

    };

    function nopass(id) {
        baseutil.post('/wx/wxeducationuser/oneImageOfStudentCheck', {"examine": "1","id":id}, function (result) {
            if (0 == result.code) {
                dialog.msg("不通过成功");
                getInfo();// 获取数据
                toPage();// 进行分页
            }else {
                dialog.msg("不通过失败");
            }
        });

    };
    function getImgId() {
        var arr = [];
        $(":checkbox[name='imageCheckbox']:checked").each(function (i, e) {
            var imgId=$(e).attr("data-imgId");
            arr.push(imgId);
        });
        var l = arr.join(",");
        return l
    }

    function getExamine() {
        var arr = [];
        $(":checkbox[name='imageCheckbox']:checked").each(function (i, e) {
            var examine=$(e).attr("data-examine");
            arr.push(examine);
        });
        var e = arr.join(",");
        return e
    }

    function getUserName() {
        var arr = [];
        $(":checkbox[name='imageCheckbox']:checked").each(function (i, e) {
            var examine=$(e).attr("data-name");
            arr.push(examine);
        });
        var e = arr.join(",");
        return e
    }



</script>
</body>
</html>































